# Create your views here.
from django.http import HttpResponse
from django.shortcuts import render_to_response
from django.contrib.admin import site 
import re
import math

class Print():
	def __init__(self,y=0,loop=0):
		self.loop = loop
		self.y = y
		
	def init_rows(self,y=0,loop=0):
		self.loop = loop
		self.y = y
	def end_rows(self):
		self.loop = 0
		self.y = 0

	def next_row(self):
		self.y += self.loop
		

	def get_reng(self,texto):
		import pygame as pg
		px = 37.795275591
		#initiate pygame
		pg.init()
	
		font = pg.font.SysFont('Arial', 16)
		text = font.render(texto, 1, (10, 10, 10))
		textpos = text.get_rect()
		textwidth = tuple(textpos)[2]
		renglones = (textwidth)/(8.2*px)
		return renglones
	
	def advance_to_reng(self,texto):
		for a in range(int(math.floor(self.get_reng(texto)))):
			self.next_row()

